<?php

error_reporting(E_ALL);

/**
 * AplicacionWeb - class.ModeloRptSalidas.php
 *
 * $Id$
 *
 * This file is part of AplicacionWeb.
 *
 * Automatically generated on 07.12.2011, 09:57:32 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * Clase que se encarga del control del acceso a la persistencia de los datos 
 * Centraliza la conexiones en los modelos
 *
 * @author Ivan R. Chenoweth
 * @since 2011
 * @version 1
 */
require_once('class.Conexion.php');

/* user defined includes */
// section -64--88-3-17--259f25fe:134142dcecc:-8000:00000000000012B9-includes begin
// section -64--88-3-17--259f25fe:134142dcecc:-8000:00000000000012B9-includes end

/* user defined constants */
// section -64--88-3-17--259f25fe:134142dcecc:-8000:00000000000012B9-constants begin
// section -64--88-3-17--259f25fe:134142dcecc:-8000:00000000000012B9-constants end

/**
 * Short description of class ModeloRptSalidas
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class ModeloRptSalidas
    extends Conexion
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    // --- OPERATIONS ---

    /**
     * Short description of method getAllRows
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function getAllRows()
    {
        // section -64--88-3-17--259f25fe:134142dcecc:-8000:00000000000012DF begin
		$sql = "SELECT 
		salidas.Salida_Id as Salida_Id,
		salidas.SalidaFecha as SalidaFecha,
		salidas.SalidaNumeroFolio as SalidaNumeroFolio,
		tbemp.EmpleadoNombre as Empleado_Id,
		tbusu.UsuarioNombre as Usuario_Id,
		salidas.FechaHoraUltimaModificacion as FechaHoraUltimaModificacion
		FROM salidas,
		(SELECT * FROM empleados) as tbemp,
		(SELECT * FROM usuarios) as tbusu
		WHERE salidas.Empleado_Id=tbemp.Empleado_Id AND
		salidas.Usuario_Id=tbusu.Usuario_Id ORDER BY Salida_Id DESC";		
		return $this->ejecutarQuery($sql);
        // section -64--88-3-17--259f25fe:134142dcecc:-8000:00000000000012DF end
    }

    /**
     * Short description of method deleteRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function deleteRow($id)
    {
        // section -64--88-3-17--259f25fe:134142dcecc:-8000:00000000000012E1 begin
		$sql= "DELETE FROM salidas WHERE Salida_Id = $id";
		$this->ejecutarQuery($sql);
        // section -64--88-3-17--259f25fe:134142dcecc:-8000:00000000000012E1 end
    }

    /**
     * Short description of method getRowByDate
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  date1
     * @param  date2
     * @return mixed
     */
    public function getRowByDate($date1 = null, $date2 = null)
    {
        // section -64--88-3-17--259f25fe:134142dcecc:-8000:00000000000012E4 begin
		$sql = "SELECT 
		salidas.Salida_Id as Salida_Id,
		salidas.SalidaFecha as SalidaFecha,
		salidas.SalidaNumeroFolio as SalidaNumeroFolio,
		tbemp.EmpleadoNombre as Empleado_Id,
		tbusu.UsuarioNombre as Usuario_Id,
		salidas.FechaHoraUltimaModificacion as FechaHoraUltimaModificacion
		FROM salidas,
		(SELECT * FROM empleados) as tbemp,
		(SELECT * FROM usuarios) as tbusu
		WHERE (salidas.Empleado_Id=tbemp.Empleado_Id AND
		salidas.Usuario_Id=tbusu.Usuario_Id) AND
		salidas.SalidaFecha>='".date("Y-m-d",strtotime($date1))."' AND salidas.SalidaFecha<='".date("Y-m-d",strtotime($date2))."' ORDER BY Salida_Id DESC";		
		return $this->ejecutarQuery($sql);
        // section -64--88-3-17--259f25fe:134142dcecc:-8000:00000000000012E4 end
    }

    /**
     * Short description of method getRowDetails
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function getRowDetails($id)
    {
        // section -64--88-3-36--c12a23e:1341972a335:-8000:00000000000012F8 begin
		$sql = "SELECT 
		salidasdetalle.Salida_Id as Salida_Id,
		salidasdetalle.SalidaDetalle_Id as SalidaDetalle_Id,
		tbart.ArticuloDescripcion as ArticuloDescripcion,
		salidasdetalle.SalidaDetalleCantidad as SalidaDetalleCantidad,
		salidasdetalle.FechaHoraUltimaModificacion as FechaHoraUltimaModificacion
		FROM salidasdetalle,
		(select * from articulos) as tbart
		WHERE (salidasdetalle.Articulo_Id=tbart.Articulo_Id) AND salidasdetalle.Salida_Id=".$id."";		
		return $this->ejecutarQuery($sql);
        // section -64--88-3-36--c12a23e:1341972a335:-8000:00000000000012F8 end
    }

} /* end of class ModeloRptSalidas */

?>